home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
vmenu.arc
/
KB.ASM
< prev
next >
Wrap
Assembly Source File
|
1985-08-25
|
2KB
|
64 lines
; kb.asm courtesy of Dr. Bob's Utilities 6/18/85
; get a key from keyboard, no wait - set hi bit if 'special' key
; code returned to calling program in ax is
;
; 0 if no key pressed
; ASCII value for regular keys
; DOS extended code + 128 (high bit set) for 'special' keys
codeseg segment word public 'code'
assume cs:codeseg
public kb_
kb_ proc near
push dx ; save dx
mov ah,1 ; tell dos we want to check typeahead status
int 16h ; is there a key waiting?
jnz getit ; yes
mov ax,0 ; if no,
jmp fin ; return 0
; a key is waiting in the buffer
getit: mov ah,0 ; tell dos to get code from buffer
int 16h
cmp al,0 ; is it a 'special' key?
je special ; yes
and ah,0 ; if no, clear ah and
jmp fin ; return ASCII value of key
special: mov al,ah ; get code in al
or al,128 ; set hi bit
and ah,0 ; clear ah
; keys with codes 128-132 need correction
; to match 'official' IBM extended codes
; these are ALT9, ALT0, ALT-, ALT=, and ^PgUp
cmp al,133 ; check for weirdness (^PgUp, alt9-alt=)
jge fin ; not wierd
add ax,128 ; correct for weirdness
fin: pop dx ; restore dx
ret ; return to caller
kb_ endp
codeseg ends
end